package nl.vu.few.ibivu.biomodels.client.place;

import com.google.gwt.place.shared.PlaceTokenizer;

public class ModelPlace extends ModellingPlace {
	
	private Long modelId;
	
    public ModelPlace(Long modelId) {
		super();
		this.modelId = modelId;
	}

	public Long getModelId() {
		return modelId;
	}

	public void setModelId(Long modelId) {
		this.modelId = modelId;
	}

	public static class Tokenizer implements PlaceTokenizer<ModelPlace> {
        @Override
        public String getToken(ModelPlace place) {
            return (place.getModelId() == null) ? "" : place.getModelId().toString();
        }

        @Override
        public ModelPlace getPlace(String token) {
        	Long modelId;
        	if (token == null)
        		modelId = null;
        	try {
        		modelId = Long.valueOf(token);
        	} catch(NumberFormatException e) {
        		modelId = null;
        	}
            return new ModelPlace(modelId);
        }
    }
}
